<?php

	$sideproductone = eto_get_option('eto_sbproductone');
	$sideproducttwo = eto_get_option('eto_sbproducttwo');
	$sideproductthree = eto_get_option('eto_sbproductthree');
	$sideproductfour = eto_get_option('eto_sbproductfour');
	$sideproductfive = eto_get_option('eto_sbproductfive');
        $sideproductsix = eto_get_option('eto_sbproductsix');
        $sideproductseven = eto_get_option('eto_sbproductseven');
        $sideproducteight = eto_get_option('eto_sbproducteight');
        $sideproductnine = eto_get_option('eto_sbproductnine');
        $sideproductten = eto_get_option('eto_sbproductten');

	$ranarray = array($sideproductone,$sideproducttwo,$sideproductthree,$sideproductfour,$sideproductfive,$sideproductsix,$sideproductseven,$sideproducteight,$sideproductnine,$sideproductten);
	$sidefeatured = array_rand($ranarray);
	$sidefeaturedproduct = $ranarray[$sidefeatured];

	$sbfeaturedproduct = new wp_query('post_type=product&number_posts=1&p='.$sidefeaturedproduct.'');
	while ($sbfeaturedproduct->have_posts()) : $sbfeaturedproduct->the_post();

	if(get_field('productFeaturedImage', $post->ID) != '') {
		$sbproductimage = get_field('productFeaturedImage', $post->ID);
	} else {
		$sbproductimage = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'large');
        $sbproductimage = $sbproductimage[0];
	}

?>

	<style>
		.sbfeaturedproduct p { text-align:center; }
			.sbfeaturedproduct .price ins { border:0px;text-decoration:none; }
				.sbfeaturedproduct .price ins span, sbfeaturedproduct .price span.amount { font-size:18px;font-weight:bold;color:#3a3f55;}
		.sbfeaturedproduct table tr:last-child td { font-weight:bold; }
		.sbfeaturedproduct p a.button { width:100%;height:40px;padding:0px;line-height:40px;font-size:15px !important;font-weight:bold; }
	</style>

	<div class="sbfeaturedproduct">

		<a href="<?php echo the_permalink(); ?>">
			<img src="<?php echo $sbproductimage; ?>" alt="<?php echo the_title(); ?>" title="<?php echo the_title(); ?>" style="width:225px;height:225px;margin:0px;margin-bottom:20px;" />
		</a>

		<p style="font-size:14px;font-weight:bold;line-height:18px;margin-bottom:10px;margin-top:0px;text-align:center;">
			<a href="<?php echo the_permalink(); ?>"><?php echo the_title(); ?></a>
		</p>

		<?php include '/home/silicons/public_html/wp-content/themes/woostore/woocommerce/single-product/price.php'; ?>

		<?php if(get_field('sbproducttable')) { ?>
			<p style="font-weight:bold;text-align:left;"><?php the_field('sbproducttabletitle'); ?></p>
			<table style="width:100%;cellpadding:0px;cellspacing:0px;border:0px;font-size:12px;font-family:arial;margin:0px;margin-bottom:10px;">
				<?php while(has_sub_field('sbproducttable')) : ?>
					<tr>
						<td style="height:30px;line-height:30px;align:left;padding-left:10px;border-top:#f2f2f2 1px solid;"><?php the_sub_field('sbproducttableleft'); ?></td>
						<td style="height:30px;line-height:30px;text-align:right;padding-right:10px;border-top:#f2f2f2 1px solid;"><?php the_sub_field('sbproducttableright'); ?></td>
					</tr>
				<?php endwhile; ?>
			</table>
		<?php } ?>

		<?php if(get_field('sbproductfeatures')) { ?>
			<ul style="border:0px;margin-bottom:20px;">
				<?php while(has_sub_field('sbproductfeatures')) : ?>
					<li style="border:0px;text-align:center;height:20px;line-height:20px;"><?php the_sub_field('sbproductfeature'); ?></li>
				<?php endwhile; ?>
			</ul>
		<?php } ?>

		<p><a class="button" href="<?php echo the_permalink(); ?>">View Product Details</a></p>

	</div>

<?php endwhile; ?>
<?php wp_reset_query(); ?>